<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>霓虹灯</title>
</head>

<body>
    <div class="light">
        <div></div>
        <div></div>
        <div></div>
        <div></div>
        Neon Button
    </div>
</body>
<style>
    body {
        background: #050901;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 500px;
    }

    .light {
        position: relative;
        padding: 25px 30px;
        width: fit-content;
        color: #03e9f4;
        font-size: 60px;
        font-family: 'Tahoma';
        text-transform: uppercase;
        transition: 0.5s;
        letter-spacing: 4px;
        cursor: pointer;
        overflow: hidden;
        /* 修改整体颜色*/
        /* filter:hue-rotate(100deg); */
    }

    .light:hover {
        background-color: #03e9f4;
        color: #050801;
        box-shadow: 0 0 5px #03e9f4,
                    0 0 25px #03e9f4,
                    0 0 50px #03e9f4,
                    0 0 200px #03e9f4;
    }
    .light div{
        position: absolute;
    }
    .light div:nth-child(1){
        width: 100%;
        height: 3px;
        top: 0;
        left: -100%;
        background: linear-gradient(to right,transparent,#03e9f4);
        animation: animate1 2s linear infinite;
    }
    .light div:nth-child(2){
        width: 3px;
        height: 100%;
        top: -100%;
        right: 0;
        background: linear-gradient(to bottom,transparent,#03e9f4);
        animation: animate2 2s linear infinite;
        animation-delay: 0.5s;
    }
    .light div:nth-child(3){
        width: 100%;
        height: 3px;
        bottom: 0;
        right: -100%;
        background: linear-gradient(to left,transparent,#03e9f4);
        animation: animate3 2s linear infinite;
        animation-delay: 1s;
    }
    .light div:nth-child(4){
        width: 3px;
        height: 100%;
        bottom: -100%;
        left: 0;
        background: linear-gradient(to top,transparent,#03e9f4);
        animation: animate4 2s linear infinite;
        animation-delay: 1.5s;
    }
    @keyframes animate1 {
        0% {
            left: -100%;
        }
        50%,100% {
            left: 100%;
        }
    }
    @keyframes animate2 {
        0% {
            top: -100%;
        }
        50%,100% {
            top: 100%;
        }
    }
    @keyframes animate3 {
        0% {
            right: -100%;
        }
        50%,100% {
            right: 100%;
        }
    }
    @keyframes animate4 {
        0% {
            bottom: -100%;
        }
        50%,100% {
            bottom: 100%;
        }
    }
</style>
<script>
    let i = 0
    let deg = 0
    function setColor() {
        const degList = [40,80,120,160,200,240,280,320,360]
        if(i >= 8) i = 0
        deg = degList[i]
        const lightDom = document.querySelector('.light')
        lightDom.style.filter = `hue-rotate(${deg}deg)`
        i++
    }
    setInterval(() => {
        setColor()
    },1000)
</script>

</html>